
[dbo].[asi_PurgePanelEditorSource]
CREATE PROCEDURE [dbo].[asi_PurgePanelEditorSource]
@panelName nvarchar(100),
@purgeData bit = 0
AS
BEGIN
SET NOCOUNT ON
DECLARE @documentKey uniqueidentifier;
DECLARE @viewName sysname;
DECLARE @sql nvarchar(1000);
SELECT @documentKey = DocumentVersionKey FROM DocumentMain WHERE DocumentName = @panelName AND DocumentTypeCode = 'BUS' AND DocumentStatusCode = 40
EXEC [dbo].[asi_DocumentDelete] @documentKey, 1;
SELECT @documentKey = DocumentVersionKey FROM DocumentMain WHERE DocumentName = @panelName AND DocumentTypeCode = 'BOD' AND DocumentStatusCode = 40
EXEC [dbo].[asi_DocumentDelete] @documentKey, 1;
SELECT @documentKey = DocumentVersionKey FROM DocumentMain WHERE DocumentName = @panelName AND DocumentTypeCode = 'DBS' AND DocumentStatusCode = 40
EXEC [dbo].[asi_DocumentDelete] @documentKey, 1;
DELETE FROM [dbo].[RuleSourceDesign] WHERE RuleName = @panelName
DELETE FROM [dbo].[RuleSourcePublish] WHERE RuleName = @panelName
SELECT @viewName = TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME LIKE '%'+ @panelName
WHILE @viewName IS NOT NULL
BEGIN
SET @sql = 'DROP VIEW ' + @viewName
EXEC (@sql)
SET @viewName = NULL
SELECT @viewName = TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME LIKE '%'+ @panelName
END
DELETE FROM [dbo].[PanelDefinition] WHERE [Name] = @panelName
DELETE FROM [dbo].[ObjectMetaData] WHERE [ObjectName] = @panelName
DELETE FROM ComponentRegistry
WHERE [Name] = @panelName AND [InterfaceName] = 'IAtom' AND [Description] = 'Auto Generated'
IF (@purgeData = 1)
BEGIN
DELETE FROM [dbo].[UserDefinedSingleInstanceProperty] WHERE [TableName] = @panelName
DELETE FROM [dbo].[UserDefinedMultiInstanceProperty] WHERE [TableName] = @panelName
END
SET NOCOUNT OFF
END
GO